package com.xbh.Book.service.impl;

import com.xbh.Book.dao.UserDao;
import com.xbh.Book.dao.impl.UserDaoImpl;
import com.xbh.Book.pojo.User;
import com.xbh.Book.service.UserService;

/**
 * @program: JavaWebExer
 * @description: UserService的实现类
 * @author: 许宝华
 * @create: 2021-04-13 09:21
 */

public class UserServiceImpl implements UserService {
    private UserDao userDao=new UserDaoImpl();
    @Override
    public void registUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        if(userDao.queryUserByUsername(username)==null){
            //等于null，说明没查到，没查到表示可用

            return false;
        }else{
            return true;
        }
    }
}
